package com.chd.driversystem.gen;

import com.chd.driversystem.util.tools.MyApplication;

/**
 * Created by feiyu on 17-5-11.
 */

public class GreenDaoManager {
    private static GreenDaoManager mInstance;
    private DaoMaster mDaoMaster;
    private DaoSession mDaoSession;

    private GreenDaoManager(){
        DaoMaster.DevOpenHelper devOpenHelper =
                new DaoMaster.DevOpenHelper(MyApplication.getContext(),"driversystem-db",null);
        mDaoMaster = new DaoMaster(devOpenHelper.getWritableDb());
        mDaoSession = mDaoMaster.newSession();
    }

    public static GreenDaoManager getInstance(){
        if(mInstance == null){
            synchronized (GreenDaoManager.class){
                if (mInstance == null){
                    mInstance = new GreenDaoManager();
                }
            }
        }
        return mInstance;
    }

    public DaoMaster getMaster(){
        return mDaoMaster;
    }
    public DaoSession getSession(){
        return mDaoSession;
    }
    public DaoSession getNewSeesion(){
        mDaoSession = mDaoMaster.newSession();
        return mDaoSession;
    }
}
